//
//  TabBarVc.m
//  new
//
//  Created by going on 16/3/15.
//  Copyright © 2016年 going_Shui. All rights reserved.
//

#import "TabBarVc.h"
#import "MainViewController.h"
#import "AboutUsViewController.h"
#import "ScanForViewController.h"
#import "MessageListViewController.h"
#import "MyCenterViewController.h"




@interface TabBarVc ()<UITabBarControllerDelegate,UIAlertViewDelegate>

{
//    TabBarVc * _tabBarVc;
}
@end

@implementation TabBarVc

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
   

    [self configTabBar];
    [self creatViewControllers];
    

}

-(void)configTabBar {
    self.tabBar.translucent = NO;
}

-(void)creatViewControllers {
    
    MainViewController * homeVC = [[MainViewController alloc]init];
    [self addChildViewController:homeVC title:@"首页"imageName:@"icon_tab_home" selectedImageName:@"icon_tab_home_click"];

    AboutUsViewController * findVC = [[AboutUsViewController alloc]init];
    [self addChildViewController:findVC title:@"关于我们" imageName:@"icon_tab_about" selectedImageName:@"icon_tab_about_click"];
    
    ScanForViewController * healthVC = [[ScanForViewController alloc]init];
    [self addChildViewController:healthVC title:@"扫一扫" imageName:@"icon_tab_scan" selectedImageName:@"icon_tab_scan_click"];
    MessageListViewController   * message= [[MessageListViewController alloc]init];
    [self addChildViewController:message title:@"消息大喇叭" imageName:@"icon_tab_news" selectedImageName:@"icon_tab_news_click"];
    MyCenterViewController   * myCenterVC = [[MyCenterViewController alloc]init];
    [self addChildViewController:myCenterVC title:@"我的" imageName:@"icon_tab_my" selectedImageName:@"icon_tab_my_click"];
}
/**
 *  封装添加vc的方法
 */
- (void)addChildViewController:(UIViewController *)childController title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
    childController.title = title;
    childController.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childController.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childController];
     [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"img_home_nav_bg"] forBarMetrics:UIBarMetricsDefault];
    
    [self addChildViewController:nav];
    
    NSDictionary * detdic =@{NSForegroundColorAttributeName:[UIColor lightGrayColor]};
    [nav.tabBarItem setTitleTextAttributes:detdic forState:UIControlStateNormal];
    //改变颜色
    NSDictionary * seledic =@{NSForegroundColorAttributeName:[UIColor redColor]};
    [nav.tabBarItem setTitleTextAttributes:seledic forState:UIControlStateSelected];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
